package blog.ideablog.controller;

import blog.ideablog.exception.BlogException;
import blog.ideablog.model.enums.ErrorInfoEnum;
import blog.ideablog.model.vo.BlogInfoVO;
import blog.ideablog.model.vo.Results;
import blog.ideablog.service.CommService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("通用接口")
@RestController
public class CommController {
    @Autowired
    private CommService commService;

    @ApiOperation("检查服务端是否正常")
    @GetMapping("/ping")
    public Results ping() {
        return Results.ok("欢迎访问ReganBlog API", null);
        //throw new BlogException(ErrorInfoEnum.MISSING_PARAMETERS);
    }

    @ApiOperation("获取博客信息")
    @GetMapping("/info")
    public Results<BlogInfoVO> info() {
        BlogInfoVO blogInfo = commService.getBlogInfo();
        return Results.ok(blogInfo);
    }
}
